﻿$(document).ready(function() 
{
    getTopUserFolders();
    getUserFolders();
 
   $("#master").grid({height:240,
                      autowidth:true,
                      multiselect: false,
                      rowNum:10,
                      colModel:[{label: "ID", name: "Userfoldersid", align: "center",hidden:true},
                                {label: "菜单名称", name: "Foldernm",  align: "left"},
                                {label: "上级菜单", name: "Parefolderid",  align: "left"},
                                { label: "圖標", name: "Iconpath", index: "Iconpath", align: "center", sortable: false, width: 65,
                                            formatter: function(value, options, row) 
                                            {
                                                if(value!="")
                                                return "<img width='55' height='55' src='../../inc/themes/css/img/applyico/" + value + "' alt='圖標' />"
                                            }
                                        },
                                {label: "页面路径", name: "Formurl", align: "left"},
                                 {label: "归属角色", name: "", align: "left"},
                                {label: "IFRAMEID", name: "Target", align: "left"}
                                ]
                        });

   $("#parefolderid").combox();

   $("#addBtn").click(openDialog);
});
function getUserFolders()
{
//       top.Core.AJAX.Post({dataType:"text",
//                                            data:{MothodName: "Class1.Test",p_arg:"123"},
//                                            fn:function(data)
//                                            { 
//                                               alert(data);
//                                            }
//        });
$.ajax({
            type: "get",
            dataType: "json",
            url: "ashx/systems.ashx",
            data: { MothodName: "GetSystemMenu", parefolderid:$("#parefolderid").val(),foldernm:$("#foldernm").val()},
            //error: top.DWZ.ajaxError,
//            beforeSend: function() { top.loaddingFN("show"); },
//            complete: function() { top.loaddingFN('hide'); },
            success: function(ret) 
            {
//                 alert(ret);
                 $("#master").gridBind(ret);
            }
        }); 
}
function getTopUserFolders()
{
        $.ajax({
            type: "get",
            dataType: "json",
            async: false,
            url: "ashx/systems.ashx",
            data: { MothodName: "GetSystemTopMenu", parefolderid:"1",foldernm:$("#foldernm").val()},
            success: function(ret) 
            {
                 $(ret).each(function(i,ei){
                       $("#parefolderid").append( "<option value=\""+ei.Userfoldersid+"\">"+ei.Foldernm+"</option>");
                 })
            }
        }); 
}
function openDialog()
{
     top.$.pdialog.open({url:"pages/system/menuset.htm",id:"MenuSet",title:"设定菜单",min:false,mask:true,width:"700",height:"500"});
} 

function getValue()
{
    alert($("#combox").select2("val"));
}

function alertConfirm()
{
    top.Message.confirm("你確定嗎？",function()
    {
        alert("OK");
    })
}

function alertMsg()
{
    top.Message.ok("操作成功？");  
    top.Message.error("操作錯誤？");  
    top.Message.warn("操作警告？");  
}

